import { UserItem } from './userModel';
import { AverageUserQueryParams } from './model';
import { BasicFetchResult } from '/@/api/model/baseMode';
import { defHttp } from '/@/utils/http/axios';
import { UploadFileParams, UploadApiResult, ExportParams } from './model';
import { ErrorMessageMode } from '/@/utils/http/axios/types';

enum Api {
  List = '/baseinfo/activityManager/findPage',
  ChangeStatus = '/baseinfo/activityManager/status',
  Recommend = '/baseinfo/activityManager/recommend',
  Delete = '/baseinfo/activityManager/delete/',
  Edit = '/baseinfo/activityManager/edit',
  Add = '/baseinfo/activityManager/add',
  Getcitylist = '/bannerManager/cityList',
  Gettitlelist = '/bannerManager/findContents',
  Upload = '/mini/getFileUrl',
  See = '/baseinfo/activityManager/findActivityMemberManager', //查看报名人数
  findCityAreaSchools = '/mini/findCityAreaSchools/', //查看报名人数

  // /baseinfo/activityManager/findById/{id}

  VideoUrl = '/mini/getVideoUrl',
  SeeList = '/baseinfo/activityManager/findById', //查看
  GetArealist = '/cityManager/findAreasById/',
  Export = '/baseinfo/activityManager/export',
  ApplyExportApi = '/baseinfo/activityManager/exportActivityMember',
}

/**
 * @description: 查询普通用户列表
 */
export function ListApi(params: AverageUserQueryParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.List,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:地址
 */
export function getfindCityAreaSchools(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.findCityAreaSchools + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 改变用户状态
 */
export function ChangeStatusApi(params: UserItem, mode: ErrorMessageMode = 'modal') {
  return defHttp.put(
    {
      url: Api.ChangeStatus,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 是否推荐
 */
export function ChangeRecommendApi(params: UserItem, mode: ErrorMessageMode = 'modal') {
  return defHttp.put(
    {
      url: Api.Recommend,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 删除用户
 */
export function DeleteApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.delete(
    {
      url: Api.Delete + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 新增销售人员
 */
export function AddApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.Add,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 编辑销售人员
 */
export function EditApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.Edit,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

// 获取城市列表
export function GetcitylistApi(mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.Getcitylist,
    },
    {
      errorMessageMode: mode,
    }
  );
}

// 根据城市获取三级地区
export function GetArealistApi(params: number | string, mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.GetArealist + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
// 获取标题列表
export function GettitlelistApi(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.Gettitlelist,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 上传banner图片
 */
export function UploadApi(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void
) {
  return defHttp.uploadFile<UploadApiResult>(
    {
      url: Api.Upload,
      onUploadProgress,
    },
    params
  );
}
/**
 * @description: 上传banner图片
 */
export function getLeaseHousesVideoUrl(
  params: UploadFileParams,

  onUploadProgress: (progressEvent: ProgressEvent) => void
) {
  return defHttp.uploadFile<UploadApiResult>(
    {
      url: Api.VideoUrl,
      onUploadProgress,
    },
    params
  );
}
/**
 * @description: 查看人数
 */
export function DetailsApi(userId: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.See + `/${userId}`,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 查看
 */
export function DetailsApiList(userId: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.SeeList + `/${userId}`,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 导出
 */
export function ExportApi(params: ExportParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.Export,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 报名人数导出
 */
export function ApplyExportApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.exportBlob(
    {
      url: Api.ApplyExportApi,
      params,
      responseType: 'blob',
    },
    {
      errorMessageMode: mode,
    }
  );
}
